﻿namespace XmlStudio.Models.Actions {
    using GuiLabs.Undo;
    using XmlStudio.Interfaces;

    /// <summary>
    /// Base abstract class for xml xmlModel actions.
    /// </summary>
    internal abstract class XmlModelAction : AbstractAction {
        #region Fields
        #region Protected
        /// <summary>
        /// Address of current action.
        /// </summary>
        protected int[] address;

        /// <summary>
        /// <see cref="IXmlModel"/> associated with the current action.
        /// </summary>
        protected IXmlModelWithNotifications model;

        /// <summary>
        /// Indicates whether the node was modified before current action took place.
        /// </summary>
        protected bool wasModified;

        /// <summary>
        /// Indicates whether the xmlModel was modified before the current action took place.
        /// </summary>
        protected bool modelWasModified;
        #endregion
        #endregion

        #region Properties
        /// <summary>
        /// Gets the address where the modification began.
        /// </summary>
        #region Public
        public int[] Address {
            get { return this.address; }
        }
        #endregion
        #endregion

        #region Constructors
        #region Public
        /// <summary>
        /// Initializes a new instance of the <see cref="XmlModelAction"/> class.
        /// </summary>
        /// <param name="model">The model.</param>
        public XmlModelAction(IXmlModelWithNotifications model) {
            this.model = model;
            this.modelWasModified = model.Modified;
        }
        #endregion
        #endregion
    }
}